<!DOCTYPE html>
<html lang="zh">
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>Document</title>
	</head>
	<body>

		<div id="app">
			<button @click="gup">更新马冬梅</button>
			<ul>
				<li v-for="(item,index) of persons" :key="item.id">
					{{item.name}}-{{item.age}}--{{index}}
					<input type="text" />
				</li>
			</ul>
		</div>
		<script src="../vue.js"></script>
		<script>
			var app = new Vue({
				el: '#app', //Id #id class .name  标签 div
				//输出的数据
				data: function() {
					return {
						persons: [{ //列表数据
								id: '001',
								name: "马冬梅",
								age: 55,
								sex: "女"
							},
							{
								id: '002',
								name: "周冬雨",
								age: 19,
								sex: "女"
							},
							{
								id: '003',
								name: "周杰伦",
								age: 20,
								sex: "男"
							},
							{
								id: '004',
								name: "马吴伦",
								age: 77,
								sex: "男"
							},
						],
					}
				},
				//页面刷新时立刻执行的代码
				mounted: function() {},
				//对象 方法
				methods: {
					gup() {
						//this.persons[0].name="666"//有用
						// this.persons[0] = {//不奏效
						// 	id: '004',
						// 	name: "马吴伦",
						// 	age: 77,
						// 	sex: "男"
						// }
						this.persons.splice(0, 1, {
							id: '004',
							name: "马吴伦",
							age: 77,
							sex: "男"
						})
					}
				},

			});
			//34 vue监视数据的原理
			//https://www.bilibili.com/video/BV1Zy4y1K7SH?p=34&spm_id_from=pageDriver&vd_source=f6fb46d92fc9158762a56ffb78684957
		</script>
	</body>
</html>
